CC     = gcc
AR     = ar
CXX    = g++
OPT    = -std=c++0x -pg
INC    = -I ../include -I /usr/include/gsl -I /usr/include/ImageMagick
LIB    = -L ../lib -lms_sphere -lms_voxelimage -lms_misc -lfe_vecmat -lgsl -lgslcblas 
LINK   = -L -lWand -lMagickCore -lpthread
		
CXXCMD = $(CXX) $(OPT) $(INC)


default:
	$(MAKE) spongebob

test: ms_test.cxx ../lib/lib*.a
	$(CXXCMD) ms_test.cxx -o ms_test $(LIB)

gsltest: gsltest.cxx ../lib/lib*.a 
	$(CXXCMD) gsltest.cxx -o gsltest $(LIB) 

spongebob:	ms_spongebob.cxx ../include/ms_spongebob.h	\
		misc		\
		voxelimage	\
		sphere		\
		distribution
	$(CXXCMD) $(LIB) $(LINK) ms_spongebob.cxx -o ms_spongebob 

clean:
	rm -rf 2> /dev/null

disttest: ms_dist_test.cxx distribution
	$(CXXCMD) ms_dist_test.cxx ms_distribution.o $(LIB) $(LINK) -o disttest


testnumber: testnumber.cxx 
	$(CXXCMD) $(LIB) $(LINK) testnumber.cxx -o testnumber 


libs: misc voxelimage sphere cylinder distribution

# ms_voxelimage.cxx ../include/ms_voxelimage.h

voxelimage: ms_voxelimage.cxx 
	$(CXXCMD) `Magick-config --cflags --cppflags` -c ms_voxelimage.cxx `Magick-config --ldflags --libs`
	$(AR) r ../lib/libms_voxelimage.a ms_voxelimage.o

misc: ms_misc.cxx ../include/ms_misc.h
	$(CXXCMD) ms_misc.cxx -c
	$(AR) r ../lib/libms_misc.a ms_misc.o 

sphere: ms_sphere.cxx ../include/ms_sphere.h
	$(CXXCMD) ms_sphere.cxx -c
	$(AR) r ../lib/libms_sphere.a ms_sphere.o 

cylinder: ms_cylinder.cxx ../include/ms_cylinder.h
	$(CXXCMD) ms_cylinder.cxx -c
	$(AR) r ../lib/libms_cylinder.a ms_cylinder.o 

distribution: ms_distribution.cxx ../include/ms_distribution.h ../include/fe_vecmat.h
	$(CXXCMD) ms_distribution.cxx -c
	$(AR) r ../lib/libms_distribution.a ms_distribution.o

vecmat: fe_vecmat.cxx ../include/fe_vecmat.h
	$(CXXCMD) $(MKLINC) $(MPIINC) fe_vecmat.cxx -c
	$(AR) r ../lib/libfe_vecmat.a fe_vecmat.o
